@extends('front.public_layout.layout')


@section('style')
    <link rel="stylesheet" href="{{asset('/front/css/village_public.css')}}">
    <link rel="stylesheet" href="{{asset('/front/css/article.css')}}">
    <style>

    </style>
@endsection

@section('content')
    <div class="middle-content article-data">

        <div class="data-list">
            <div class="mingsheng">

            </div>
            <div class="more-btn" onclick="article_list()">查看更多</div>
        </div>



        {{--    农品热销--}}
        <div class="goods-adv">
            <div class="title">农品热销</div>

            @foreach($hotGoods as $hotGoodsVal)
                <a class="goods-adv-item" href="{{ url('shop/details/'.$hotGoodsVal->id) }}">
                    <div class="goods-img">
                        <img src="{{ $hotGoodsVal->goods_img_url }}" alt="">
                    </div>
                    <div class="goods-name">{{ $hotGoodsVal->goods_name }}</div>
                    <div class="price">{{ $hotGoodsVal->acticity_price }}元</div>
                </a>
            @endforeach

        </div>
    </div>

@endsection


@section('js')

    <script>

        function article_html(item) {
            html = '<div class="ms-item">';
            html += '<a href="'+'{{ url('village_publish/details') }}'+'/'+item.id+'">';

            html += '   <div class="class-one-img">';
            if (item.list_img_url) {
                html += '       <div class="a-img left">';
                html += '           <img src="'+item.list_img_url+'" alt="">';
                html += '       </div>';
            }
            html += '       <div class="a-title">【'+item.region_info.region_name+'】'+item.pub_title+'</div>';
            html += '       <div class="a-intro">'+item.pub_intro+'</div>';
            html += '       <div class="clear"></div>';
            html += '   </div>';

            html += '</a>';
            html += '   <div class="a-opt">';
            if (item.is_admin) {
                html += '       <a class="tip-info" href="'+'{{url('author')}}'+'/'+item.village_pub_admin_author.id+'/1'+'">';
                html += item.village_pub_admin_author.name;
            } else {
                html += '       <a class="tip-info" href="'+'{{url('author')}}'+'/'+item.village_pub_author.id+'">';
                if (item.village_pub_author.real_name) {
                    html += item.village_pub_author.real_name;
                } else {
                    html += item.village_pub_author.user_name;
                }
            }
            html += '       </a>';
            html += '       <div class="time">'+item.created_at+'</div>';
            html += '       <div class="right">';
            html += '           <div class="zan">'+item.zan_num+'</div>';
            html += '           <div class="read">'+item.read_num+'</div>';
            html += '       </div>';
            html += '   </div>';
            html += '</div>';

            return html;
        }

        var article_url = '{{ url('ajax_village_publish_lists') }}';
        function article_list(categoryid) {
            $.post(article_url, {
                _token: '{{ csrf_token() }}',
                category_id: categoryid
            }, function (data) {
                if (data.status == 1) {
                    if (data.data.next_page_url) {
                        article_url = data.data.next_page_url;
                        $('.more-btn').show();
                    } else {
                        $('.more-btn').hide();
                    }

                    var html = '';
                    $.each(data.data.data,function(index,item){
                        html += article_html(item);
                    });

                    $('.mingsheng').append(html);


                } else {

                }
            }, 'json');
        }
        article_list();

    </script>
@endsection